﻿using CampusTrade.Pojo;
using CampusTrade.Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace CampusTrade.Controller
{
    [Route("api/[controller]")]
    [ApiController]
    public class GoodController : ControllerBase
    {
        private readonly GoodService goodService;
        public GoodController(GoodService goodService)
        {
            this.goodService = goodService;
        }

        /**
         * 获取分类信息
         */
        [HttpGet("getClassifications")]
        public List<Classification> getAllClassifications()
        {
            return goodService.getClassifications();
        }
        /**
         * 分页查询获取供需列表
         */
        [HttpGet("getGoodList/{pageStart}/{pageSize}/{cid}")]
        public Dictionary<string, object> getGoodList(int pageStart, int pageSize, int cid)
        {
            return null;
        }
        /**
         * 搜索商品信息
         */
        [HttpGet("searchGoodList/{keyWord}")]
        public Dictionary<string, object> searchGoodList(string keyWord)
        {
            return null;
        }
        /**
         * 发布供需信息
         */
        [HttpPost("addGood")]
        public long addGood(Good good)
        {
            good.StatusId = 1;
            return goodService.addGood(good);
        }
        /**
         * 删除供需信息
         */
        [HttpDelete("delGood/{id}")]
        public int deleteGood(long id)
        {
            return goodService.deleteGood(id);
        }
        /**
         * 获取待审核的供需列表
         * 供需信息status为1
         */
        [HttpGet("getNeedGoodList")]
        public Dictionary<string, object> getNeedGoodList()
        {
            return null;
        }
        /**
         * 获取关于自己的发布列表
         */
        [HttpGet("getMyReleaseGoodList/{uid}")]
        public Dictionary<string, object> getMyReleaseGoodList(long uid)
        {
            return null;
        }
        /**
         * 审核通过 
         * 更改供需信息状态为2
         */
        [HttpPut("verifySuccess")]
        public int verifySuccess(long goodId)
        {
            return goodService.changeStatus(goodId, 2);
        }
    }
}
